<%@ page language="java" contentType= "text/html" pageEncoding="UTF-8"%>
<%@include file="/include/common/formuihead1.jsp"%>
<%
	page1.getPageTitle().setEnab(false);
%>
<%@include file="/include/common/formuihead2.jsp"%>
<%
	page1.getPageTitle().setTitle("菜單管理right");
%>
<jm:form>
<jm:layout postion="north">
	<jm:toolbar deleteDisabled="<%=form.gpiv("lastsn") == 0 ? "true" : "false"%>"  exportDisabled="true" newDisabled="false" newEnab="false" printDisabled="true" />
	<jm:pageTitle />
</jm:layout>

<jm:layout postion="center">
	<jm:error></jm:error>  
	<jm:dp id="dp1" data="<%=Utils.TAG_FORM%>" tabSize="1">
		<jm:tab colModel="300px;*">
			<jm:group colspan="2" hidden="true"> 
				<input name="menusn" caption="主鍵值" type="text"/> 
				<input name="lastsn" caption="上一層主鍵" type="text"/>
			</jm:group>
			
			<input name="name" caption="名稱" type="text"  width="200px"/>
			<input name="src" caption="鏈接" type="text"  width="200px"/>
			<jm:select name="open" caption="展開" codeList="false|否;true|是" emptySupported="false"  width="200px"/>
			<jm:select name="enab" caption="狀態" codeList="1|啟用;0|取消" emptySupported="false"  width="200px"/>
			<jm:select name="public" caption="是否公開" codeList="1|公開;0|不公開" emptySupported="false"  width="200px"/>
			<input name="srt" caption="排序" type="text" width="200px"/>
			<jm:field keep="true">
				<jm:button value="設置權限" name="setprivilege" style="width:100px" icon="sx-tb-assist" onclick="<%="doprivilege("+form.gpsv("menusn")+")"%>"/>
			</jm:field>
		</jm:tab>
	</jm:dp> 
	<br>
	<jm:columnEditors>
		<jm:columnEditor id="e_name" type="text">
			<input name="e_name" type="text"/>
		</jm:columnEditor>
		<jm:columnEditor id="e_src" type="text">
			<input name="e_src" type="text"/>
		</jm:columnEditor>
		<jm:columnEditor id="e_srt" type="text">
			<input name="e_srt" type="text"/>
		</jm:columnEditor>
		<jm:columnEditor id="e_open" type="select">
			<jm:select name="e_open" codeList="false|否;true|是" emptySupported="false"/>
		</jm:columnEditor>
		<jm:columnEditor id="e_enab" type="select">
			<jm:select name="e_enab"  codeList="1|啟用;0|取消" emptySupported="false"/>
		</jm:columnEditor>
	</jm:columnEditors>
	<jm:table id="grid1" dataSet="<%=ret.getSerchResult()%>" toolbar="true" loopFisrt="true"  
		addRowConfig="reset:grid_reset" toolbarConfig="deleteRowEnab:true"
		deleteRowConfig="tr:grid1_deleterow" >
		<jm:thead>
			<tr><td colspan="7" style="font-size: 12px;font-weight: bold;">子目錄</td></tr>
			<tr>
				<td width="30px">選</td>
				<td width="150px" config="cid:'name',editor:'text',editorid:'e_name'">名稱</td>
				<td width="300px" config="cid:'src',editor:'text',editorid:'e_src'">鏈接</td>
				<td width="50px" config="cid:'open',editor:'select',editorid:'e_open',width:50">展開</td>
				<td width="50px" config="cid:'enab',editor:'select',editorid:'e_enab',width:50">狀態</td>
				<td width="50px" config="cid:'srt',editor:'text',editorid:'e_srt'">排序</td>
				<td width="*" >&nbsp;</td>
			</tr>
		</jm:thead>
		<jm:tbody>
			<jm:tr>
				 <jm:td cid="col1"><input type="checkbox" name="key" value="<%=ret.grsv("sn")%>" />
				 	<input type="hidden" name="sn" value="<%=ret.grsv("sn")%>" />
				 </jm:td>
				<jm:td cid="name"></jm:td>
				<jm:td cid="src"></jm:td>
				<jm:td cid="open"></jm:td>
				<jm:td cid="enab"></jm:td>
				<jm:td cid="srt"><%=ret.grsv("srt","1")%></jm:td>
				<jm:td cid="col1">
					<%if(ret.griv("sn") >0){%>
					<jm:button value="設置權限" name="setprivilege" style="width:100px" icon="sx-tb-assist" onclick="<%="doprivilege("+ret.grsv("sn")+")"%>"/>
					<%}%>
				</jm:td>
				
			</jm:tr>
		</jm:tbody>
	</jm:table>
</jm:layout>
</jm:form>
<jm:script><script type="text/javascript" charset="UTF-8">
	function onsave(actionvalue,p){
		var records = $('table[id=grid1] tbody tr[dirty=true]').getRecords();
		$P.form.appendRecords(records);
		submitForm(p);
	}
	
	//以下定义其它function ,命名要取有意义的名称
	function grid_reset(tr){
		tr.find('input[name=sn],input[name=key]').val('');
		tr.find('td[cid!=srt]').html('&nbsp;');
		tr.find('td[cid=srt]').text($('td[cid=srt]').length+1);
		tr.find('td[cid=open]').attr('value','false').text('否');
		tr.find('td[cid=enab]').attr('value','1').text('啟用');
	}
	
	function grid1_deleterow(tr){
		var keys = $('input[name=key]:checked');
		var len = keys.length;
		if(len == 0) return ;
		var len2 = 0
		keys.each(function(){
			if(this.value == ""){
				$(this).parent().parent().remove();
				len2++;
			}else{
				len2 = 0;
				return;
			}
		});
		
		if(len != len2){
			doAction({action:'delete',actionvalue:'deleteRow'});
		}
		delete len;
		delete len2;
		delete keys;
		return null;
	}
	
	function doprivilege(sn){
		$P.openwin("/jmPro/subPro/admin/admin002.jsp?menusn="+sn, "privilege","", "", 0,0);
	}
</script></jm:script>
<%@include file="/include/common/formuiend.jsp"%>
